package com.springboot.test;

import com.springboot.test.properties.Car;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.ConfigurableApplicationContext;

import java.util.Map;
import java.util.Properties;
import java.util.Set;

/**
 * @author likai
 * @date 2021/9/30 2:55 PM
 * @email likai9376@163.com
 * @desc
 */
//@EnableAutoConfiguration
//@ComponentScan(basePackages = "com.springboot.test")
//
//

@SpringBootApplication
@EnableConfigurationProperties(Car.class)
//@SpringBootConfiguration
//@EnableAutoConfiguration
//@ComponentScan(value = "com.springboot.test")
public class MyApplication {


    public static void main(String[] args) {
        ConfigurableApplicationContext run = SpringApplication.run(MyApplication.class, args);

//        DispatcherServlet bean = run.getBean(DispatcherServlet.class);
//        System.out.println(bean);


//        String[] beanDefinitionNames = run.getBeanDefinitionNames();
//
//        for (String beanName : beanDefinitionNames) {
//            System.out.println(beanName);
//        }
//
//        String[] beanNamesForType = run.getBeanNamesForType(Cat.class);
//
//        for (String s : beanNamesForType) {
//            System.out.println(s);

//        }

//        System.out.println("==============env");
//        Map<String, String> getenv = System.getenv();
//
//        Set<String> strings = getenv.keySet();
//
//        for (String key:strings){
//            System.out.println("key==="+key+",value====="+getenv.get(key));
//        }
//        System.out.println("size:"+strings.size());

        String property = run.getEnvironment().getProperty("spring.application.name");
        System.out.println(property);


        Properties properties = System.getProperties();
        Set<Object> objects = properties.keySet();
        for (Object key:objects){
            System.out.println("key,"+key+",value:"+properties.getProperty(key.toString()));
        }


        System.out.println("pro.size:"+objects.size());
    }
}
